<div class="layui-card-header layui-card">
    <span class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">首页</a>
        <a><cite>商户</cite></a>
    </span>
</div>
<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-tab layui-tab-brief">
      <ul class="layui-tab-title">
        <li class="layui-this">支付通道</li>
      </ul>
      <div class="layui-tab-content">
        <style>
          .center {
            width: 80%;
          }
        </style>
        <table class="layui-hide center" id="cList"></table>
      </div>
    </div>
  </div>
</div>
<script>
  layui.use(['table','util'], function(){
    var $ = layui.$
            ,admin = layui.admin
            ,table = layui.table
            ,element = layui.element
            ,form = layui.form;

    element.render('breadcrumb', 'breadcrumb');//渲染导航信息

    var router = layui.router();
    var mchId = router.search.mchId;

    var tplStatus = function(d){
      if(d.status == 0) {
        return "关闭";
      }else if(d.status == 1) {
        return "<span style='color: green'>开启</span>";
      }
    };

    var tplMchRate = function(d){
      if(d.mchRate == '' || d.mchRate == null) {
        return "未设置";
      }else {
        if(d.agentRate > d.mchRate) {
          return "<span style='color: red'>"+ d.mchRate+"%<span>";
        }else {
          return "<span style='color: blue'>"+ d.mchRate+"%<span>";
        }

      }
    };
      var tplFixedAmount = function(d){
          if(d.fixedAmount == '' || d.fixedAmount == null) {
              return "未设置";
          }else {
              return "<span style='color: blue'>"+ d.fixedAmount+"<span>";
          }
      };

    table.render({
      elem: '#cList'
      ,url: layui.setter.baseUrl + '/mch_pay_passage/list'
      ,where: {
        mchId: mchId ,
        access_token: layui.data(layui.setter.tableName).access_token
      }
      ,cols: [[
        {field:'productId', title: '产品ID'}
        ,{field:'productName', title: '产品名称'}
        ,{field:'mchRate', title: '商户费率',templet: tplMchRate}
        ,{field:'fixedAmount', title: '固定金额',templet: tplFixedAmount}
        ,{field:'status', title: '状态',templet: tplStatus }
      ]]
      ,page: false
      ,skin: 'line'
    });
  });

</script>
